package com.huangwei.test;


import com.huang.serializer.CommonSerializer;
import com.huang.transport.RpcClientProxy;
import com.huang.transport.socket.client.SocketRpcClient;
import com.huangwei.rpc.api.ByeService;
import com.huangwei.rpc.api.HelloObject;
import com.huangwei.rpc.api.HelloService;


/**
 * 测试用消费者（客户端）
 */
public class SocketTestClient {
    public static void main(String[] args) {
        //初始化客户端
        SocketRpcClient client = new SocketRpcClient(CommonSerializer.KRYO_SERIALIZER);
        //初始化动态代理
        RpcClientProxy proxy = new RpcClientProxy(client);
        //和动态代理绑定
        HelloService helloService = proxy.getProxy(HelloService.class);
        HelloObject object = new HelloObject(12, "This is a message");

        //动态代理交给服务端执行，得到返回值
        String res = helloService.hello(object);
        System.out.println(res);
        ByeService byeService = proxy.getProxy(ByeService.class);
        System.out.println(byeService.bye("Netty"));
    }
}
